#ifndef _SYSTEM_H
#define _SYSTEM_H

#include <hidef.h> /* for EnableInterrupts macro */
#include "derivative.h" /* include peripheral declarations */
#include <string.h>
#include <stdlib.h>
#include "DataTypes.h"
#include "Clock.h"
#include "Serial.h"
#include "Timers.h"
#include "ADC.h"
#include "BoardSupport.h"

#include "MC9S08LL64.h"
#include "SimpleMessaging.h"
#include "CRC.h"
#include "FirmwareVersion.h"
#include "AutoNV.h"

#define SCI_BAUD_RATE   57600


#define SYSTEM_STATE_INIT            0x00
#define SYSTEM_STATE_IDLE            0x01
#define SYSTEM_STATE_AUTO_NV         0x02

extern BYTE SystemState;

void InitSystemVariables(void);
void EnterSystemState(BYTE NextState);

void SendSmartCarStatusToHost(void);

extern volatile BYTE HostUpdateTimer;
#define HOST_UPDATE_TIME  5


extern BOOL ButtonPressed[4];


#define SW1_PRESSED ButtonPressed[0]
#define SW2_PRESSED ButtonPressed[1]
#define SW3_PRESSED ButtonPressed[2]
#define SW4_PRESSED ButtonPressed[3]

void InitButtonDetect(void);
void ButtonDetect(void);

#define AUTO_NV_START_TIMER GPTimer[0]

#endif
